#include "functions.h"
#include <avr/interrupt.h>
#include <avr/portpins.h>
#include <util/delay.h>

void doDelay(unsigned int miliseconds){
	unsigned int l=(miliseconds/40);
	unsigned int i;
	for(i=0; i < l; ++i) _delay_ms(40);
}

void waitFor(unsigned int miliseconds){
	miliseconds=miliseconds;
	doDelay(miliseconds);
}


unsigned int changeBit(unsigned int bits, unsigned int bitNum, unsigned int isON){
	unsigned int curBitOn=(1<<bitNum);
	unsigned int ret=bits;

	if (isON){
		ret |= curBitOn;
	}else{
		ret &= ~(curBitOn);
	}
	return ret;
}

int isBitOn(unsigned int byte, unsigned int bitCheck) {
	return isBitMskOn(byte, (1<<bitCheck));
}
int isBitMskOn(unsigned int byte, unsigned int bitMask) {
	unsigned int ret=0;

	if ((byte & bitMask)==bitMask){
		ret=1;
	}
	return ret;
}
